/*
 * Copyright (c) 2011 Jean-Marc Perronne
 * Ensisa, 12 rue des Freres Lumieres, F-68093 Mulhouse cedex
 * All rights reserved.
 *
 * The copyright of this software is owned by Werner Randelshofer. 
 * You may not use, copy or modify this software, except in  
 * accordance with the license agreement you entered into with  
 * Jean-Marc Perronne. For details see accompanying license terms. 
 */

package fr.uha.ensisa.jmp.drone.at_commands;

public class AtPcmCommand  extends AbstractAtCommand
{
	private boolean enable;
	private float leftRightTilt;
	private float frontBackTilt;
	private float verticalSpeed;
	private float angularSpeed;

	public AtPcmCommand()
	{
		super("PCMD");
		this.enable = false;
		this.leftRightTilt = 0f;
		this.frontBackTilt = 0f;
		this.verticalSpeed = 0f;
		this.angularSpeed = 0f;
	}

	public void param(boolean enable, float leftRightTilt, float frontBackTilt, float verticalSpeed, float angularSpeed)
	{
		this.unReady();
		this.enable = enable;
		this.leftRightTilt = leftRightTilt;
		this.frontBackTilt = frontBackTilt;
		this.verticalSpeed = verticalSpeed;
		this.angularSpeed = angularSpeed;
	}
	
	public boolean isEnable()
	{
		return this.enable;
	}

	public float leftRightTilt()
	{
		return this.leftRightTilt;
	}

	public float frontBackTilt()
	{
		return this.frontBackTilt;
	}

	public float verticalSpeed()
	{
		return this.verticalSpeed;
	}

	public float angularSpeed()
	{
		return this.angularSpeed;
	}

	@Override
	protected void appendParamaters(StringBuilder builder)
	{
		builder.append(',').append((this.enable)?1:0);
		builder.append(',').append(Float.floatToIntBits(this.leftRightTilt));
		builder.append(',').append(Float.floatToIntBits(this.frontBackTilt));
		builder.append(',').append(Float.floatToIntBits(this.verticalSpeed));
		builder.append(',').append(Float.floatToIntBits(this.angularSpeed));
	}
}
